--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
scripts/ci/macos-normalize-pycodec2-dylib.sh f46e70249c407897bc3d43952fe0a8b401afe630 (f46e7024) Text, 3.16 KB
T8b949e#!/usr/bin/env bash
T8b949e# Normalize the installed pycodec2 package's bundled libcodec2 into a fixed,
T8b949e# arch-independent relative layout:
T8b949e#
T8b949e# pycodec2/pycodec2*.so (extension module, @loader_path/libcodec2.dylib)
T8b949e# pycodec2/libcodec2.dylib (single canonical name, no .dylibs/ subfolder)
T8b949e#
T8b949e# Published macOS wheels bundle libcodec2 under pycodec2/.dylibs/libcodec2.<ver>.dylib
T8b949e# (delocate convention). Building pycodec2 from sdist for architectures without a
T8b949e# published wheel (e.g. cp314 macOS x86_64) instead links against whatever Homebrew
T8b949e# codec2 path was on LDFLAGS at build time. Without normalization the two cx_Freeze
T8b949e# build trees (darwin-arm64 vs darwin-x64) have different relative file layouts for
T8b949e# the same logical dependency, so scripts/unify-backend-plain-files.sh treats the
T8b949e# bundled dylib as arch-only and drops it from BOTH trees, breaking Codec2 audio
T8b949e# (voice messages) in the shipped universal macOS app.
T8b949e#
T8b949e# Usage: macos-normalize-pycodec2-dylib.sh <python-executable>
Tffa657set -euo pipefail
Te6edf3PYTff7b72=Ta5d6ff"Tffd700${Te6edf31Tb4b4b4:Tb4b4b4?usageTb4b4b4:Tb4b4b4 macos-normalize-pycodec2-dylib.sh <python-executable>Tffd700}Ta5d6ff"
Tff7b72if Tff7b72[Tff7b72[ Ta5d6ff"Tff7b72$(uname -sTff7b72)Ta5d6ff" !Tff7b72= Ta5d6ff"Darwin" Tff7b72]Tff7b72]Tb4b4b4; Tff7b72then
Tffa657echo Ta5d6ff"macos-normalize-pycodec2-dylib: skipping (not macOS)" >Tb4b4b4&T79c0ff2
Tffa657exit T79c0ff0
Tff7b72fi
Te6edf3_site_dirTff7b72=Ta5d6ff"Tff7b72$(Ta5d6ff"Te6edf3$PYTa5d6ff" -c Ta5d6ff'import pycodec2, pathlib; print(pathlib.Path(pycodec2.__file__).resolve().parent)' T79c0ff2>/dev/null Tff7b72|| Tffa657trueTff7b72)Ta5d6ff"
Tff7b72if Tff7b72[Tff7b72[ -z Ta5d6ff"Te6edf3$_site_dirTa5d6ff" Tff7b72|| ! -d Ta5d6ff"Te6edf3$_site_dirTa5d6ff" Tff7b72]Tff7b72]Tb4b4b4; Tff7b72then
Tffa657echo Ta5d6ff"macos-normalize-pycodec2-dylib: pycodec2 not installed, skipping" >Tb4b4b4&T79c0ff2
Tffa657exit T79c0ff0
Tff7b72fi
Te6edf3_ext_soTff7b72=Ta5d6ff"Tff7b72$(find Ta5d6ff"Te6edf3$_site_dirTa5d6ff" -maxdepth T79c0ff1 -name Ta5d6ff'pycodec2*.so' -print -quitTff7b72)Ta5d6ff"
Tff7b72if Tff7b72[Tff7b72[ -z Ta5d6ff"Te6edf3$_ext_soTa5d6ff" Tff7b72]Tff7b72]Tb4b4b4; Tff7b72then
Tffa657echo Ta5d6ff"Ta5d6ffmacos-normalize-pycodec2-dylib: no pycodec2 extension module found under Tffd700${Te6edf3_site_dirTffd700}Ta5d6ff, skippingTa5d6ff" >Tb4b4b4&T79c0ff2
Tffa657exit T79c0ff0
Tff7b72fi
Te6edf3_targetTff7b72=Ta5d6ff"Tffd700${Te6edf3_site_dirTffd700}Ta5d6ff/libcodec2.dylibTa5d6ff"
Te6edf3_dylibs_dirTff7b72=Ta5d6ff"Tffd700${Te6edf3_site_dirTffd700}Ta5d6ff/.dylibsTa5d6ff"
Te6edf3_src_dylibTff7b72=Ta5d6ff""
Tff7b72if Tff7b72[Tff7b72[ -d Ta5d6ff"Te6edf3$_dylibs_dirTa5d6ff" Tff7b72]Tff7b72]Tb4b4b4; Tff7b72then
Te6edf3_src_dylibTff7b72=Ta5d6ff"Tff7b72$(find Ta5d6ff"Te6edf3$_dylibs_dirTa5d6ff" -maxdepth T79c0ff1 -name Ta5d6ff'libcodec2*.dylib' -print -quitTff7b72)Ta5d6ff"
Tff7b72fi
Tff7b72if Tff7b72[Tff7b72[ -z Ta5d6ff"Te6edf3$_src_dylibTa5d6ff" Tff7b72]Tff7b72]Tb4b4b4; Tff7b72then
Tff7b72for _candidate Tff7b72in Ta5d6ff"Tffd700${Te6edf3_site_dirTffd700}Ta5d6ff/libcodec2.dylibTa5d6ff" Ta5d6ff"Tffd700${Te6edf3_site_dirTffd700}Ta5d6ff/libcodec2.soTa5d6ff"Tb4b4b4; Tff7b72do
Tff7b72if Tff7b72[Tff7b72[ -f Ta5d6ff"Te6edf3$_candidateTa5d6ff" Tff7b72]Tff7b72]Tb4b4b4; Tff7b72then
Te6edf3_src_dylibTff7b72=Ta5d6ff"Te6edf3$_candidateTa5d6ff"
Tff7b72break
Tff7b72fi
Tff7b72done
Tff7b72fi
Tff7b72if Tff7b72[Tff7b72[ -z Ta5d6ff"Te6edf3$_src_dylibTa5d6ff" Tff7b72]Tff7b72]Tb4b4b4; Tff7b72then
Tffa657echo Ta5d6ff"Ta5d6ffmacos-normalize-pycodec2-dylib: no bundled libcodec2 found under Tffd700${Te6edf3_site_dirTffd700}Ta5d6ff, skippingTa5d6ff" >Tb4b4b4&T79c0ff2
Tffa657exit T79c0ff0
Tff7b72fi
Tff7b72if Tff7b72[Tff7b72[ Ta5d6ff"Te6edf3$_src_dylibTa5d6ff" !Tff7b72= Ta5d6ff"Te6edf3$_targetTa5d6ff" Tff7b72]Tff7b72]Tb4b4b4; Tff7b72then
cp -f Ta5d6ff"Te6edf3$_src_dylibTa5d6ff" Ta5d6ff"Te6edf3$_targetTa5d6ff"
Tff7b72fi
Tff7b72if Tff7b72[Tff7b72[ -d Ta5d6ff"Te6edf3$_dylibs_dirTa5d6ff" Tff7b72]Tff7b72]Tb4b4b4; Tff7b72then
rm -rf Ta5d6ff"Te6edf3$_dylibs_dirTa5d6ff"
Tff7b72fi
Tff7b72if Tff7b72[Tff7b72[ -f Ta5d6ff"Tffd700${Te6edf3_site_dirTffd700}Ta5d6ff/libcodec2.soTa5d6ff" Tff7b72&& Ta5d6ff"Tffd700${Te6edf3_site_dirTffd700}Ta5d6ff/libcodec2.soTa5d6ff" !Tff7b72= Ta5d6ff"Te6edf3$_targetTa5d6ff" Tff7b72]Tff7b72]Tb4b4b4; Tff7b72then
rm -f Ta5d6ff"Tffd700${Te6edf3_site_dirTffd700}Ta5d6ff/libcodec2.soTa5d6ff"
Tff7b72fi
Te6edf3_old_refTff7b72=Ta5d6ff"Tff7b72$( Tff7b72(otool -L Ta5d6ff"Te6edf3$_ext_soTa5d6ff" Tb4b4b4| awk Ta5d6ff'/libcodec2/{print $1; exit}'Tff7b72)Ta5d6ff 2>/dev/null || true)Ta5d6ff"
Tff7b72if Tff7b72[Tff7b72[ -n Ta5d6ff"Te6edf3$_old_refTa5d6ff" Tff7b72&& Ta5d6ff"Te6edf3$_old_refTa5d6ff" !Tff7b72= Ta5d6ff"@loader_path/libcodec2.dylib" Tff7b72]Tff7b72]Tb4b4b4; Tff7b72then
install_name_tool -change Ta5d6ff"Te6edf3$_old_refTa5d6ff" Ta5d6ff"@loader_path/libcodec2.dylib" Ta5d6ff"Te6edf3$_ext_soTa5d6ff"
codesign --force --sign - Ta5d6ff"Te6edf3$_ext_soTa5d6ff" >/dev/null T79c0ff2>Tb4b4b4&T79c0ff1 Tff7b72|| Tffa657true
Tffa657echo Ta5d6ff"Ta5d6ffmacos-normalize-pycodec2-dylib: rewrote Tffd700${Te6edf3_old_refTffd700}Ta5d6ff -> @loader_path/libcodec2.dylib in Tff7b72$(basename Ta5d6ff"Te6edf3$_ext_soTa5d6ff"Tff7b72)Ta5d6ff"
Tff7b72fi
Tffa657echo Ta5d6ff"Ta5d6ffmacos-normalize-pycodec2-dylib: normalized Tff7b72$(basename Ta5d6ff"Te6edf3$_ext_soTa5d6ff"Tff7b72)Ta5d6ff + libcodec2.dylib under Tffd700${Te6edf3_site_dirTffd700}Ta5d6ff"
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────